const app=getApp();
//获取列表
  const getList=function(who,page,limit,list,type){
	  wx.showLoading({
      title: '加载中',
    });
    wx.request({
      url: app.globalData.baseUrl +'donggu/list', 
      method: 'POST',
      data: {
        page: page,
        limit: limit,
        dg_type:type
      },
      header: {
        'content-type': 'application/x-www-form-urlencoded'
      },
      success: res => {
		  let resData=res.data;
            if(resData.success){
				wx.hideLoading();
				who.setData({
					loadSuccess:true
				});
              let resList=res.data.result.list;
			  who.setData({
				dg_list:[...list,...resList]
			  });
              if(resList.length<limit){
				
                who.setData({
					noData:true,
					isLoad:false
				});
				return false;
              }
			  who.data.page++;
			  
            }
            else{
              who.setData({
                noData: true,
                isLoad: false
              });
            }
      }
    })
  }

  //获取推荐的
  const getSwiper= function (who,type) {
    wx.request({
      url: app.globalData.baseUrl +'donggu/recom', 
      method: 'POST',
      data: { dg_type: type},
      header: {
        'content-type': 'application/x-www-form-urlencoded'
      },
      success: res => {
        if (res.data.success) {
          who.setData({
            sw_list: res.data.result.list
          })
        }

      }
    })
  }
  //一些数据
  const someData={
		indicatorDots: true,
		autoplay: true,
		interval: 5000,
		duration: 300,
		dg_list:[],
		sw_list:[],
		page:0,
		limit:6,
		isLoad:true,
		noData:false,
		loadSuccess:false,
    baseUrl: app.globalData.baseUrl
  }
  
module.exports={
	getList,
	getSwiper,
	someData
}  
  